package com.ruoyi.comment.service.impl;

import com.ruoyi.comment.domain.CommentContent;
import com.ruoyi.comment.mapper.CommentContentMapper;
import com.ruoyi.comment.service.ICommentContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletionService;

@Service
public class ICommentContentServiceImpl implements ICommentContentService {
    @Autowired
    private CommentContentMapper commentContentMapper;
    @Override
    public void insert(CommentContent commentContent) {
        CommentContent insert = commentContentMapper.insert(commentContent);
    }

    @Override
    public void delete(String id) {
           commentContentMapper.deleteById(id.toString());
    }

    @Override
    public void update(CommentContent commentContent) {
      delete(commentContent.getId());
      insert(commentContent);

    }

    @Override
    public List<CommentContent> list() {
        return commentContentMapper.findAll();
    }

    @Override
    public CommentContent getById(String id) {
        Optional<CommentContent> content = commentContentMapper.findById(id);
        CommentContent commentContent = content.get();
        return commentContent;
    }
}
